package com.kingyun.gpsinspection.purificationservice.facade.service.jsm.employee;

import com.alibaba.fastjson.JSONObject;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.Employee;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.EmployeeCertificateVo;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.EmployeeVo;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.Ztree;

import java.util.List;
import java.util.Map;

/**
 * Created by zmling on 2016/11/22.
 * 人员信息
 */
public interface JsmEmployeeService {

    /**
     * 新增人员信息
     *
     * @param employee
     * @param employeeCertificate
     * @param uploadFiles
     * @param deletedFiles
     * @throws Exception
     */
    void employeeAdd(Employee employee, List<EmployeeCertificateVo> employeeCertificate, String uploadFiles, String deletedFiles, Employee e, String uploadSignature) throws Exception;

    /**
     * 分页查询
     *
     * @param employee
     * @return
     * @throws Exception
     */
    JSONObject findEmployeeList(Employee employee) throws Exception;

    /**
     * 通过主键I的查询
     *
     * @param employeeId
     * @return
     * @throws Exception
     */
    EmployeeVo findEmployeeById(String employeeId) throws Exception;

    /**
     * 修改人员信息
     *
     * @param employee
     * @param employeeCertificate
     * @param uploadFiles
     * @param deletedFiles
     * @throws Exception
     */
    void employeeUpdate(Employee employee, List<EmployeeCertificateVo> employeeCertificate, String uploadFiles, String deletedFiles, Employee e, String uploadSignature) throws Exception;

    /**
     * 删除人员信息
     *
     * @param employee
     * @return
     * @throws Exception
     */
    int deletEemployee(Map employee) throws Exception;


    /**
     * 查询所有人员信息
     *
     * @param employee
     * @return
     * @throws Exception
     */
    List<EmployeeVo> queryList(Employee employee) throws Exception;

    /**
     * 外部接口，查询所有人员信息
     *
     * @param employee
     * @return
     * @throws Exception
     */
    List<EmployeeVo> findEmployees(Employee employee) throws Exception;


    /**
     * 根据角色和部门查询或者其他查询人员信息
     *
     * @return
     */
    List<EmployeeVo> queryEmployeeByRoleDept(Map selectMap);

    /**
     * @param list
     * @Author 卢曼成
     * @Description 批量插入
     * @Date 2017/2/8 18:04
     */
    int insertList(List<Employee> list);

    /**
     * @param list
     * @Author 卢曼成
     * @Description 批量修改
     * @Date 2017/2/8 17:18
     */
    int updateList(List<Employee> list);

    /**
     * @param list
     * @Author 卢曼成
     * @Description 批量逻辑删除
     * @Date 2017/2/8 17:18
     */
    int deleteList(List<Employee> list);

    /**
     * 加载人员混合树
     *
     * @param orgId
     * @param sync
     * @param openOrg
     * @param openDept
     * @param keyword
     * @return
     * @throws Exception
     */
    List<Ztree> loadEmployeeZtree(String orgId, boolean sync, boolean openOrg, boolean openDept, String keyword) throws Exception;

    /**
     * 获取指定组织下的所有后代组织、后代部门、后代人员的混合树
     *
     * @param orgId
     * @return
     */
    List<Ztree> getEmployeeMixedZtreeByOrgId(String orgId) throws Exception;

    /**
     * 人员混合树的设置组织的ztree的isParent
     *
     * @param ztree
     * @param orgId
     * @throws Exception
     */
    void setOrgZtreeIsParent(Ztree ztree, String orgId) throws Exception;

    /**
     * 人员混合树的设置部门的ztree的isParent
     *
     * @param ztree
     * @param orgId
     * @throws Exception
     */
    void setDepZtreeIsParent(Ztree ztree, String orgId) throws Exception;

    /**
     * @param orgId              组织机构Id
     * @param isLoadOrg          是否加载组织
     * @param isLoadDept         是否加载部门
     * @param isLoadOrgEmployee  加载机构下面的人
     * @param isLoadDeptEmployee 加载部门下的人
     * @param maxLevel           显示组织的最大层级
     * @param lessLevel          显示组织的最小层级
     * @param keyword            搜索值
     */
    List<Ztree> loadEmployeeZtree(String orgId, boolean isLoadOrg, boolean isLoadDept,
                                  boolean isLoadOrgEmployee, boolean isLoadDeptEmployee, String maxLevel, String lessLevel, String keyword) throws Exception;


    /**
     * @Author 卢曼成
     * @Description 根据org查询该节点人员
     * @Date 2017/3/11 17:01
     */
    public List<Ztree> loadEmployeeZtree(String orgId) throws Exception;

    /**
     * @param employeeId
     * @return Employee
     * @Author 卢曼成
     * @Description 根据ID查询
     * @CreateDateTime 2017/3/15 14:53
     **/
    public Employee queryByKeyId(String employeeId);

    /**
     * @param list
     * @return List<String>
     * @Author 卢曼成
     * @Description 根据ID查询数据是否存在
     */
    List<String> selectByListId(List<Employee> list);

    /**
     * @param list
     * @return List<String>
     * @Author 卢曼成
     * @Description 根据postId获取关联的用户数量
     */
    int selectByPostCount(List<String> list);

    /**
     * @param employee 根据条件查询 人员信息 { 主要用于组织查询人 和 部门查询人信息 }
     */
    List<Employee> selectListEmploye(Employee employee);

    /**
     * @param employeeId
     * @param email
     * @return boolean
     * @Author 卢曼成
     * @Description 验证邮箱是否重复
     */
    boolean isExisEmail(String employeeId, String email);

    /**
     * @param employeeId
     * @param loginId
     * @return boolean
     * @Author 卢曼成
     * @Description 验证用户名是否重复
     */
    boolean isExisLogId(String employeeId, String loginId);
}
